<?php
namespace app\indexLogin\model;
use think\Db;
use think\Model;

class WeiboNice extends Model{
    protected $pk='wnid';
    protected $table='wb_weiboNice';
    /**
     * 添加数据
     */
    public function add($data){
        if(Db::table('wb_weiboNice')->where('uid','=',$data['uid'])->where('wid','=',$data['wid'])->select()){
            //该用户已经点过赞
            $weibocounts=Db::table('wb_weiboNice')->where('wid','=',$data['wid'])->count();
           return ['valid'=>0,'weibocounts'=>$weibocounts];die;
        }
        $res=$this->save($data);
//        查询当前微博的点赞数
        $weibocounts=Db::table('wb_weiboNice')->where('wid','=',$data['wid'])->count();
        return ['valid'=>1,'weibocounts'=>$weibocounts];die;
    }
}